package org.calzz.jajb.io;

/**
 * Main interface for writing Java objects to a JSON string.
 * 
 * @author Marek Brodziak <marek.brodziak@gmail.com>
 * @author Piotr Pejas <piotr.pejas@gmail.com>
 * @since Feb 6, 2008
 */
public interface IWriter {

	/**
	 * Starts a new object in JSON format.
	 * 
	 * @param name name of the object
	 */
	void startObject(String name);

	/**
	 * Ends a previously started JSON object.
	 */
	void endObject();

	/**
	 * Starts a new array in JSON format.
	 * 
	 * @param name name of the array
	 */
	void startArray(String name);

	/**
	 * Ends a previously started array.
	 */
	void endArray();

	/**
	 * Writes a key in JSON format followed by a value.
	 * 
	 * @param value key value
	 */
	void writeKey(String value);

	/**
	 * Value for a certain key, can be an object, array or primitive type.
	 * @param value object value
	 */
	void writeValue(String value);
	
	/**
	 * String value for a certain key.
	 * @param value object value
	 */
	void writeString(String value);
}
